"""author: wenyao
   data: 2021/5/17
   project: devopscmdb
"""
# class A:
#     pass

# a1 = A()
#a1 是 A 创建的
# print(type(a1))
#python中一切皆对象， 类也是对象， 类也是由另外一个类创建的
# print(type(A))

# type: #创建类的类，称之为元类

# class Animal():
#     def __init__(self,name):
#         self.name = name
#
#     def eat(self):
#         print(" i am eating....")

# def init(self,name):
#     self.name = name
#
# def eat(self):
#     print(" i am eating......")

# Animal = type("Animal",(object,),{"__init__":init,"eat":eat,"name1":"sc"})
# a1 = Animal("sc1")
# a1.eat()
# print(a1.name, a1.name1)

#元类可以规定类的一些行为
# class MyMate(type):
#     def __new__(cls, name, bases, attrs):
#         if "foo" not in attrs:
#             raise TypeError("必须设置属性foo！")
#         attrs["test"] = "mymate test!"
#         return type.__new__(cls, name, bases, attrs)
#
# class A(metaclass=MyMate):
#     foo = "foo......"
#
# print(A.foo, A.test)
# print(type(A))

#type  object
#面向对象有两种关系
#1、继承关系  object是所有类的父类，是最顶层的类
#2、实例与类的关系 type是最顶层的类
#
# print(type(object))
# print(type(type))
# print(object.__bases__)
# print(type.__bases__)
#
# object = type(object)
#相当于一种鸡生蛋 蛋生鸡的关系  先有鸡还是先有蛋


